package com.medicine.sys.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.medicine.sys.entity.Department;
import com.medicine.sys.entity.Role;
import com.medicine.sys.mapper.DepartmentMapper;
import com.medicine.sys.param.DepartmentParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DepartmentService extends ServiceImpl<DepartmentMapper, Department> {


    public IPage<Department> selectPageList(DepartmentParam departmentParam){
        Page<Department> departmentPage = new Page<>(departmentParam.getPage(),departmentParam.getSize());
        return page(departmentPage,new QueryWrapper<Department>().lambda().like(StringUtils.isNotEmpty(departmentParam.getName()),Department::getName,departmentParam.getName())
                /*.eq(Department::getMerchantId,"").eq(Department::getOrgId,"")*/);   //后续加入登录补上
    }

    public List<Department> selectList(){
        return list(new QueryWrapper<Department>().lambda().eq(Department::getMerchantId,"").eq(Department::getOrgId,""));  //后续加入登录补上
    }

    public void install(Department department){
        saveOrUpdate(department);
    }

    public Department getId(String id){
        return getById(id);
    }
}
